home *** CD-ROM | disk | FTP | other *** search
/ Aminet 44 / Aminet 44 (2001)(GTI - Schatztruhe)[!][Aug 2001].iso / Aminet / dev / src / ChunkyStartup2.lha / ChunkyStartup2K1 / test.c < prev    next >
C/C++ Source or Header  |  2001-04-07  |  4KB  |  111 lines

  1. /*==========================================================*/
  2. /*====                                                  ====*/
  3. /*====                                                  ====*/
  4. /*====      MKD's ChunkyStartup use test                ====*/
  5. /*====      krabob@online.fr 5/04/2001                  ====*/
  6. /*====                                                  ====*/
  7. /*====                                                  ====*/
  8. /*==========================================================*/
  9. /*
  10.  vbcc example:
  11.  
  12. vc +env:vc.config68k test.c ChunkyStartup.o  KZoomSprite.o ChunkyDebug.o  -v -o Test! -+ -lamiga
  13.  
  14. */
  15.  
  16. /* C-Standard includes */
  17. #include    <stdio.h>
  18. /* Amiga-Standard Includes */
  19. #include    <exec/types.h>
  20.  
  21. #include    "ChunkyStartup.h"   /* for ChunkyStartup.o */
  22. #include    "KZoomSprite.h"     /* a drawing routine */
  23. #include    "ChunkyDebug.h"     /* some debug help */
  24.  
  25. /*===================================================*/
  26. /*====                                           ====*/
  27. /*====      Example Main                         ====*/
  28. /*====                                           ====*/
  29. /*===================================================*/
  30. int     main( void )
  31. {
  32.         /*--------------------------------------------*/
  33.         char    *ChunkyScreen=NULL;
  34.         struct  ScreenRenderContext     RC;
  35.         struct  TextureContext          TC;
  36.         struct  CSAllocCell             *TextureFile,*PaletteFile;
  37.         int x1,y1,x2,y2;
  38.  
  39.         /*----- initiate screen stuffs and timer ----*/
  40.         /* set (0,240) and you'll see an asl requester  */
  41.         if ( ChunkyStartupInit(0,512)==0 ) ex_out("no screen");
  42.  
  43.         /*----- Load Texture and allocate chunky buffer -----*/
  44.         if ( (ChunkyScreen = Allocatechunkyforscreen()) == 0L  ) ex_out(NULL);
  45.         if ( (TextureFile=LoadRmb("Texture.Chunky")) == 0L ) ex_out("Texture.Chunky failed");
  46.         if ( (PaletteFile=LoadRmb("Texture.LoadRGB32")) == 0L ) ex_out("palette load failed");
  47.  
  48.         /*----- Set Screen Palette  -----*/
  49.         SetScreenPalette((ULONG*)(PaletteFile->csac_Buffer));
  50.  
  51.         /*----- Init structures for screen and texture for zoom effect -----*/
  52.         RC.src_ChunkyScreen =   ChunkyScreen    ;
  53.         RC.src_BytesModulo  =   ScreenWidth     ;
  54.         RC.src_ClipX1       =   10 ;
  55.         RC.src_ClipY1       =   10 ;
  56.         RC.src_ClipX2       =   ScreenWidth -10 ;
  57.         RC.src_ClipY2       =   ScreenHeight -10  ;
  58.  
  59.         TC.ttc_ChunkyTexture = TextureFile->csac_Buffer;
  60.         TC.ttc_BytesModulo      =   256 ;
  61.         TC.ttc_U1               =   10<<16;
  62.         TC.ttc_V1               =   10<<16;
  63.         TC.ttc_U2               =   240<<16;
  64.         TC.ttc_V2               =   240<<16;
  65.  
  66.         x1 = ScreenWidth ; /* flipped at start */
  67.         y1 = ScreenHeight ;
  68.         x2 = 0;
  69.         y2 = 0 ;
  70.  
  71.         /*-------------------------------------------*/
  72.         /*----              main loop           -----*/
  73.         while ( ListenEnd() == 0 )
  74.         {
  75.             /* draw a zooming texture  */
  76.             KZoomSprite8bit68K( x1,y1,x2,y2, &RC, &TC );
  77.  
  78.             /* print the date value */
  79.             ShowInt( GetTaskTime(),160+RC.src_BytesModulo*0,RC.src_BytesModulo,RC.src_ChunkyScreen );
  80.             ShowInt( ScreenWidth,24+RC.src_BytesModulo*8,RC.src_BytesModulo,RC.src_ChunkyScreen );
  81.             ShowInt( ScreenHeight ,24+RC.src_BytesModulo*17,RC.src_BytesModulo,RC.src_ChunkyScreen );
  82.  
  83.             /* draw everything */
  84.             ScreenRefresh(ChunkyScreen);
  85.  
  86.             /**/
  87.             x1-=1;
  88.             y1-=1;
  89.             x2+=1;
  90.             y2+=1;
  91.  
  92.         }
  93.  
  94.         ex_out(NULL);
  95.         return(0L);
  96. }
  97. /*===================================================*/
  98. /*====                                           ====*/
  99. /*====      Close Everything                     ====*/
  100. /*====                                           ====*/
  101. /*===================================================*/
  102. void    ex_out( char *errorstring  )
  103. {
  104.     /*--- error string for an "easy request"---*/
  105.     Exitmessage = errorstring;
  106.     ChunkyStartupClose();  /* close what was opened by ChunkyStartupInit */
  107.  
  108.     /*----- quit task -----*/
  109.     exit(0);
  110. }
  111.